Skip to content

Fix: item count number is not correctly shown for Quick start catalog …#413

Merged
nicolethoen merged 2 commits into
patternfly:mainfrom
charlesmulder:cm-item-count-number
Sep 5, 2025
Merged

Fix: item count number is not correctly shown for Quick start catalog …#413
nicolethoen merged 2 commits into
patternfly:mainfrom
charlesmulder:cm-item-count-number

Conversation

@charlesmulder

Copy link
Copy Markdown
Contributor

Fix for #412

The getResource function handles pluralization by referring to a JSON hash map
https://github.com/patternfly/patternfly-quickstarts/blob/main/packages/module/src/locales/en/quickstart.json

I am assuming {{ count, number }} is indicating that count should be of type number.

@netlify

netlify Bot commented Sep 3, 2025

Copy link
Copy Markdown

Deploy Preview for quickstarts ready!

Name Link
🔨 Latest commit ea910f9
🔍 Latest deploy log https://app.netlify.com/projects/quickstarts/deploys/68b86373f458d00008610207
😎 Deploy Preview https://deploy-preview-413--quickstarts.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@nicolethoen nicolethoen changed the title Fix item count number is not correctly shown for Quick start catalog … Fix: item count number is not correctly shown for Quick start catalog … Sep 3, 2025
@charlesmulder

charlesmulder commented Sep 5, 2025

Copy link
Copy Markdown
Contributor Author

@nicolethoen It may be worth considering an extension of the getResources function so that it more intuitively supports use cases like:

getResource('{{count, number}} item', quickStartsCount)

Below is a list of the files where getResource is called, along with the number of occurrences per file:

packages/module/src/ConsoleInternal/components/markdown-view.tsx:1
packages/module/src/ConsoleInternal/components/utils/status-box.tsx:2
packages/module/src/ConsoleShared/src/components/markdown-extensions/MarkdownCopyClipboard.tsx:2
packages/module/src/ConsoleShared/src/components/markdown-extensions/inline-clipboard-extension.tsx:1
packages/module/src/ConsoleShared/src/components/markdown-extensions/multiline-clipboard-extension.tsx:1
packages/module/src/QuickStartCatalogPage.tsx:5
packages/module/src/QuickStartCloseModal.tsx:4
packages/module/src/QuickStartPanelContent.tsx:3
packages/module/src/catalog/QuickStartTile.tsx:4
packages/module/src/catalog/QuickStartTileDescription.tsx:5
packages/module/src/catalog/QuickStartTileFooter.tsx:4
packages/module/src/catalog/Toolbar/QuickStartCatalogFilterItems.tsx:4
packages/module/src/controller/QuickStartConclusion.tsx:2
packages/module/src/controller/QuickStartFooter.tsx:6
packages/module/src/controller/QuickStartIntroduction.tsx:2
packages/module/src/controller/QuickStartTaskReview.tsx:3
packages/module/src/controller/QuickStartTasks.tsx:1
packages/module/src/utils/quick-start-context.tsx:1

@nicolethoen

Copy link
Copy Markdown
Contributor

@charlesmulder what sort of improvement to the helper function are you envisioning?
Is it that it could parse and replace that {{ x, y }} placeholder string?

@charlesmulder

Copy link
Copy Markdown
Contributor Author

@nicolethoen Yes exactly. Doing so will eliminate the need for additional replace() calls when placeholders are included.

// current
getResource("{{count, number}} item", quickStartsCount).replace('{{count, number}}', quickStartsCount)

// proposed
getResource("{{count, number}} item", quickStartsCount)

Even more intuitive would be to adopt a more conventional printf()-style specifier replacement:

getResource("%d item", quickStartsCount); // specifier is an int
getResource("%s item", quickStartsCount); // specifier is a string

@nicolethoen

Copy link
Copy Markdown
Contributor

As long as we are prepared to handle any usages of getResource() which may not use the same placeholder formatting, then I have no objections to that.

We probably cannot replace the {{ count, number }} formatting as that is part of the preexisting API that products are leveraging to format their content for the quickstarts. That would be considered a breaking change and PF avoids that unless absolutely necessary.

@charlesmulder

charlesmulder commented Sep 5, 2025

Copy link
Copy Markdown
Contributor Author

Oh yes, that makes sense. That probably means code outside of your control is already relying on the getResource().replace() approach for translation strings, which wouldn’t be compatible with calling getResource directly on its own. It would likely require introducing a new function that wraps getResource to handle this more cleanly.

I don’t want to complicate things, and this definitely shouldn’t form part of this PR.

Thanks for the clarification and for sharing your insights!

@nicolethoen nicolethoen merged commit 4c62cde into patternfly:main Sep 5, 2025
9 checks passed
@github-actions

github-actions Bot commented Sep 5, 2025

Copy link
Copy Markdown

🎉 This PR is included in version 6.3.0-prerelease.8 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants